package com.derbysoft.synxisadapter.dswitch2.translator.impl;

import com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType;

import java.util.HashMap;
import java.util.Map;

public abstract class TransactionStatusConverter {
    private static final Map<String, TransactionStatusType> TRANSACTION_STATUS_MAP = createTransactionStatusMap();

    private static Map<String, TransactionStatusType> createTransactionStatusMap() {
        HashMap<String, TransactionStatusType> map = new HashMap<String, TransactionStatusType>();
        for (TransactionStatusType transactionStatusType : TransactionStatusType.values()) {
            map.put(transactionStatusType.getValue(), transactionStatusType);
        }
        return map;
    }

    public static TransactionStatusType convert(String resResponseType) {
        if (TRANSACTION_STATUS_MAP.containsKey(resResponseType)) {
            return TRANSACTION_STATUS_MAP.get(resResponseType);
        }
        throw new IllegalArgumentException(String.format("Invaild ResResponseType [%s]", resResponseType));
    }
}
